/* 
*  Copyright (C) 2009-2010 WCG Project
*
*  This program is free software; you can redistribute it and/or modify it
*  under the terms of the GNU General Public License as published by the
*  Free Software Foundation; either version 2 of the License, or (at
*  your option) any later version.
*
*  This program is distributed in the hope that it will be useful, but
*  WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
*  General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software Foundation,
*  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*  In addition, as a special exception, the author gives permission to
*  link the code of this program with the Half-Life Game Engine ("HL
*  Engine") and Modified Game Libraries ("MODs") developed by Valve,
*  L.L.C ("Valve"). You must obey the GNU General Public License in all
*  respects for all of the code used other than the HL Engine and MODs
*  from Valve. If you modify this file, you may extend this exception
*  to your version of the file, but you are not obligated to do so. If
*  you do not wish to do so, delete this exception statement from your
*  version.
*/


SM_Init()
{
	for( new i = 0 ; i < MAX_SKILLS ; i++ )
		g_SkillReq[i] = SKILL_NONE

	GLOBAL_InitSkills()
	DRUID_InitSkills()
	HUNTER_InitSkills()
	MAGE_InitSkills()
	PALADIN_InitSkills()
	PRIEST_InitSkills()
	ROGUE_InitSkills()
	SHAMAN_InitSkills()
	WARLOCK_InitSkills()
}


//-------------------------------------------
// SM_UpdateClassSkills
//
// Updates the list of skills available for the specified class
//-------------------------------------------
SM_UpdateClassSkills( id, iClass )
{
	new i, iSkillID, iNum = 0

	static iSkills[MAX_SKILLS]

	// Loop through all possible skills to and set if they are available or not
	for( i = 0; i < MAX_SKILLS; i++ )
	{
		if( g_SkillOwner[i] == iClass || g_SkillOwner[i] == CLASS_GLOBAL )
			g_AvailableSkills[id][iNum++] = i
	}

	g_NumAvailableSkills[id] = iNum

	if( iNum <= 1 )
		return

	// Sort skills
	iNum = 0
	for( i = 0; i < g_NumAvailableSkills[id]; i++ )
	{
		iSkillID = g_AvailableSkills[id][i]

		if( g_SkillOwner[iSkillID] == CLASS_GLOBAL )
			iSkills[iNum++] = iSkillID
	}

	for( i = 0; i < g_NumAvailableSkills[id]; i++ )
	{
		iSkillID = g_AvailableSkills[id][i]

		if( g_SkillOwner[iSkillID] != CLASS_GLOBAL && g_SkillType[iSkillID] == SKILL_TYPE_TRAINABLE )
			iSkills[iNum++] = iSkillID
	}

	for( i = 0; i < g_NumAvailableSkills[id]; i++ )
	{
		iSkillID = g_AvailableSkills[id][i]

		if( g_SkillOwner[iSkillID] != CLASS_GLOBAL && g_SkillType[iSkillID] == SKILL_TYPE_ULTIMATE )
			iSkills[iNum++] = iSkillID
	}

	for( i = 0; i < g_NumAvailableSkills[id]; i++ )
	{
		iSkillID = g_AvailableSkills[id][i]

		if( g_SkillOwner[iSkillID] != CLASS_GLOBAL && g_SkillType[iSkillID] == SKILL_TYPE_ABILITY )
			iSkills[iNum++] = iSkillID
	}

	for( i = 0; i < g_NumAvailableSkills[id]; i++ )
		g_AvailableSkills[id][i] = iSkills[i]
}


//-------------------------------------------
// SM_InitSkill
//
//-------------------------------------------
SM_InitSkill( iSkillID, iClassID, iSkillType, iSkillMaxLevel, iSkillMinLevelReq=1, iSkillCoolDown=0, iReqSkillID=SKILL_NONE )
{
	if( !IsValidSkill( iSkillID ) )
	{
		WC3_Log( false, "[SM_InitSkill] Unknown skill id: %d", iSkillID )
		log_error( AMX_ERR_NATIVE, "[SM_InitSkill] Unkown skill id: %d", iSkillID )
		return
	}

	if( iClassID != CLASS_GLOBAL && !IsValidClass( iClassID ) )
	{
		WC3_Log( false, "[SM_InitSkill] Unknown class id: %d", iSkillID )
		log_error( AMX_ERR_NATIVE, "[SM_InitSkill] Unkown class id: %d", iSkillID )
		return
	}	

	if( iReqSkillID != SKILL_NONE && !IsValidSkill( iReqSkillID ) )
	{
		WC3_Log( false, "[SM_InitSkill] Unknown required skill id: %d", iReqSkillID )
		log_error( AMX_ERR_NATIVE, "[SM_InitSkill] Unkown required skill id: %d", iReqSkillID )
		return
	}

	g_SkillOwner[iSkillID]		= iClassID
	g_SkillType[iSkillID]		= iSkillType
	g_SkillMaxLevel[iSkillID]	= iSkillMaxLevel
	g_SkillLevelReq[iSkillID]	= iSkillMinLevelReq
	g_SkillCooldown[iSkillID]	= iSkillCoolDown
	g_SkillReq[iSkillID]		= iReqSkillID
}




//-------------------------------------------
// SM_GetSkillCastTime
//
//-------------------------------------------
Float:SM_GetSkillCastTime( iSkillID )
{
	if( !IsValidSkill( iSkillID ) )
	{
		WC3_Log( false, "[SM_GetSkillCastTime] Invalid skill: %d", iSkillID )
		log_error( AMX_ERR_NATIVE, "[SM_GetSkillCastTime] Invalid skill: %d", iSkillID )
		return 0.0
	}

	switch( iSkillID )
	{
		case ABILITY_TRANQUILITY:	return 1.0
		case ABILITY_CHAINHEAL:		return 1.0
	}
	return 0.0
}




//-------------------------------------------
// SM_GetSkillAvailable
//
// Returns true if the skill is available for selection
//-------------------------------------------
SM_GetSkillAvailable( id, iSkillID, szMsg[]="", len=0 )
{
	static szTmp[16]

	if( !IsValidSkill( iSkillID ) )
	{
		WC3_Log( false, "[SM_GetSkillAvailable] Invalid skill: %d", iSkillID )
		log_error( AMX_ERR_NATIVE, "[SM_GetSkillAvailable] Invalid skill: %d", iSkillID )
		return false
	}


	new iSkillLevel = g_PlayerSkillLevel[id][iSkillID]
	if( iSkillLevel >= g_SkillMaxLevel[iSkillID] )
	{
		if( len > 0 )
			szMsg[0] = 0
			
		return false
	}

	new bool:bReqLevel = ( PlayerInfo[id][PI_Level] < (g_SkillLevelReq[iSkillID] + iSkillLevel) )


	// Does this skill require another skill to be selected first?
	if( g_SkillReq[iSkillID] != SKILL_NONE && g_PlayerSkillLevel[id][g_SkillReq[iSkillID]] <= 0 )
	{
		if( len > 0 )
		{
			formatex( szTmp, 15, "SKILL_%d", g_SkillReq[iSkillID] )
			formatex( szMsg, len, "(Req %L)", id, szTmp )
		}
		return false
	}
	
	else if( bReqLevel )
	{
		if( len > 0 )
			formatex( szMsg, len, "(Req lv.%d)", (g_SkillLevelReq[iSkillID] + iSkillLevel) )
		return false
	}
	
	return true
}




//-------------------------------------------
// SM_SkillsAvailable
//
// Returns true if there are any skills available for selection
//-------------------------------------------
bool:SM_SkillsAvailable( id )
{
	static iSkillID

	if( PlayerInfo[id][PI_Level] - SM_TotalSkillPointsUsed( id ) <= 0 )
		return false

	for( new i = 0 ; i < g_NumAvailableSkills[id] ; i++ )
	{
		iSkillID = g_AvailableSkills[id][i]
		if( SM_GetSkillAvailable( id, iSkillID, szTmpMsg, 31 ) )
			return true
	}
	return false
}




//-------------------------------------------
// SM_GetManaCost
//
//-------------------------------------------
SM_GetManaCost( id, iSkillID, overrideSkillLevel=0 )
{
	static iSkillLevel

	if( !IsValidSkill( iSkillID ) )
	{
		WC3_Log( false, "[SM_GetManaCost] Invalid skill: %d", iSkillID )
		log_error( AMX_ERR_NATIVE, "[SM_GetManaCost] Invalid skill: %d", iSkillID )
		return 10
	}
	
	if( overrideSkillLevel )
		iSkillLevel = overrideSkillLevel
	else
		iSkillLevel = SM_GetSkillLevel( id, iSkillID )

	if( iSkillLevel <= 0 )
		return 10

	new iManacost = 10
	
	switch( iSkillID )
	{
		case ULTIMATE_DIVINEPROTECTION:	iManacost = 50
		case ULTIMATE_BEASTWITHIN:		iManacost = 30
		case ULTIMATE_IMMOLATE:			iManacost = 40
		case ULTIMATE_ENTANGLE:			iManacost = 60
		case ULTIMATE_STEALTH:			iManacost = 30
		case ULTIMATE_CHAINLIGHTNING:	iManacost = 60
		case ABILITY_POLYCHICKEN:		iManacost = 40
		case ABILITY_SERPENTWARD:		iManacost = 15
		case ABILITY_TRANQUILITY:		iManacost = p_tranquility_manacost[iSkillLevel-1]
		case ABILITY_CHAINHEAL:			iManacost = p_chainheal_manacost[iSkillLevel-1]
		case ULTIMATE_BLINK:			iManacost = 25
		case SKILL_SIPHONMANA:			iManacost = p_siphon_manacost[iSkillLevel-1]
		case SKILL_RESURRECT:			iManacost = 30
		case SKILL_BLASTWAVE:			iManacost = 20
		case ULTIMATE_BINDINGHEAL:		iManacost = p_bindingheal_manacost[iSkillLevel-1]
		case ABILITY_HOLYLIGHT:			iManacost = p_holylight_manacost[iSkillLevel-1]
	}
	
	if( PlayerBuffInfo[id][BUFF_BeastWithin] == true )
		iManacost /= 2
	
	return iManacost
}



//-------------------------------------------
// SM_SetSpawnCooldowns
//
// Default cooldowns when a player spawns
//-------------------------------------------
SM_SetSpawnCooldowns( id )
{
	static iSkillID

	for( iSkillID = 0 ; iSkillID < MAX_SKILLS ; iSkillID++ )
		PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:iSkillID)] = 0
		
	PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:ULTIMATE_STEALTH)]			= 10
	PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:ULTIMATE_CHAINLIGHTNING)]		= 10
	PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:ULTIMATE_ENTANGLE)]			= 10
	PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:ULTIMATE_IMMOLATE)]			= 10
	PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:ULTIMATE_DIVINEPROTECTION)]	= 10
	PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:ULTIMATE_BEASTWITHIN)]		= 10
	PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:ULTIMATE_BINDINGHEAL)]		= 10
	PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:ABILITY_SERPENTWARD)]			= 10
	PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:ABILITY_POLYCHICKEN)]			= 10
	PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:ULTIMATE_BLINK)]				= 10
	PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:ABILITY_TRANQUILITY)]			= 10
	PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:ABILITY_CHAINHEAL)]			= 10
	PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_SOULSTONE)]				= 10
	PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_RESURRECT)]				= 10
}



//-------------------------------------------
// SM_SetCooldown
//
//-------------------------------------------
SM_SetCooldown( id, iSkillID, Seconds=-1 )
{
	if( !IsValidSkill( iSkillID ) )
	{
		WC3_Log( false, "[SM_SetCooldown] Invalid skill: %d", iSkillID )
		log_error( AMX_ERR_NATIVE, "[SM_SetCooldown] Invalid skill: %d", iSkillID )
		return
	}
	
	if( Seconds == -1 )
		PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:iSkillID)] = g_SkillCooldown[iSkillID]
	else
		PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:iSkillID)] = Seconds
}


//-------------------------------------------
// SM_IsOnCooldown
//
//-------------------------------------------
stock SM_IsOnCooldown( id, iSkillID )
{
	if( !IsValidSkill( iSkillID ) )
	{
		WC3_Log( false, "[SM_IsOnCooldown] Invalid skill: %d", iSkillID )
		log_error( AMX_ERR_NATIVE, "[SM_IsOnCooldown] Invalid skill: %d", iSkillID )
		return true
	}
		
	if( PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:iSkillID)] > 0 )
		return true
		
	return false
}


//-------------------------------------------
// SM_UpdateCooldowns
//
//-------------------------------------------
SM_UpdateCooldowns( id )
{
	// Update ultimate
	new iSkillID = PlayerInfo[id][PI_SelectedUltimate]
	if( IsValidSkill( iSkillID ) )
	{
		PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:iSkillID)] = \
			max( --PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:iSkillID)], 0 )
	}

	// Update ability
	iSkillID = PlayerInfo[id][PI_SelectedAbility]
	if( IsValidSkill( iSkillID ) )
	{
		PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:iSkillID)] = \
			max( --PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:iSkillID)], 0 )
	}


	// Update everything else
	switch( PlayerInfo[id][PI_Class] )
	{
		case CLASS_ROGUE:
		{
			PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_CHEATDEATH)] = \
				max( --PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_CHEATDEATH)], 0 )
		}

		case CLASS_PALADIN:
		{
			PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_HOJ)] = \
				max( --PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_HOJ)], 0 )
		}

		case CLASS_SHAMAN:
		{
		}

		case CLASS_DRUID:
		{
		}

		case CLASS_WARLOCK:
		{
			PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_BANISH)] = \
				max( --PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_BANISH)], 0 )

			PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_SIPHONMANA)] = \
				max( --PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_SIPHONMANA)], 0 )

			PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_SOULSTONE)] = \
				max( --PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_SOULSTONE)], 0 )
		}

		case CLASS_HUNTER:
		{
			PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_WINGCLIP)] = \
				max( --PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_WINGCLIP)], 0 )

			PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_SERPENTSTING)] = \
				max( --PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_SERPENTSTING)], 0 )

			PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_ARCANESHOT)] = \
				max( --PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_ARCANESHOT)], 0 )
		}

		case CLASS_PRIEST:
		{
			PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_SMITE)] = \
				max( --PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_SMITE)], 0 )

			PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_RESURRECT)] = \
				max( --PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_RESURRECT)], 0 )
		}

		case CLASS_MAGE:
		{
			PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_FROSTBOLT)] = \
				max( --PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_FROSTBOLT)], 0 )

			PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_BLASTWAVE)] = \
				max( --PlayerInfo[id][PI_SpellCooldown+(S_PLAYERINFO:SKILL_BLASTWAVE)], 0 )
		}

	}
}




//-------------------------------------------
// SM_ResetSkillLevels
//
// Function will reset all of the user's skill levels
//-------------------------------------------
SM_ResetSkillLevels( id )
{
	for( new i = 0; i < MAX_SKILLS; i++ )
		g_PlayerSkillLevel[id][i] = 0

	PlayerInfo[id][PI_SelectedUltimate] = SKILL_NONE
	PlayerInfo[id][PI_SelectedAbility] = SKILL_NONE
}



//-------------------------------------------
// SM_GetSkillByPos
//
// Function will return the skill ID number based on the position (i.e. used after a skill is selected)
//-------------------------------------------
SM_GetSkillByPos( id, iPos )
{
	if( iPos < 0 || iPos >= g_NumAvailableSkills[id] )
		return SKILL_NONE

	new iSkillID = g_AvailableSkills[id][iPos]

	if( IsValidSkill( iSkillID ) )
		return iSkillID
	
	return SKILL_NONE
}



//-------------------------------------------
// SM_GetSkillLevel
//
// Returns the user's level for a certain skill
//-------------------------------------------
SM_GetSkillLevel( id, skill_id, debug_id = -1 )
{
	if( !IsValidSkill( skill_id ) )
	{
		WC3_Log( false, "[0] Invalid skill: %d [%d]", skill_id, debug_id )
		log_error( AMX_ERR_NATIVE, "[0] Invalid skill: %d [%d]", skill_id, debug_id )
		return 0
	}

	return g_PlayerSkillLevel[id][skill_id]
}



//-------------------------------------------
// SM_SetSkillLevel
//
// Set the user's skill level for a given skill
//-------------------------------------------
SM_SetSkillLevel( id, skill_id, iLevel, iDebugID )
{
	if( !IsValidSkill( skill_id ) )
	{
		WC3_Log( false, "[1] Invalid skill: %d (%d)", skill_id, iDebugID )
		log_error( AMX_ERR_NATIVE, "[1] Invalid skill: %d (%d)", skill_id, iDebugID )
		return
	}

	// We shouldn't have a skill level greater than the skills max level
	if( iLevel > g_SkillMaxLevel[skill_id] )
	{
		WC3_Log( false, "Setting skill %d to %d wtf?? (%d)", skill_id, iLevel, iDebugID )
		log_error( AMX_ERR_NATIVE, "Setting skill %d to %d wtf?? (%d)", skill_id, iLevel, iDebugID )
		return
	}
	
	// Set our new skill value
	g_PlayerSkillLevel[id][skill_id] = iLevel

	// This will configure the skill (make any changes that should be necessary)
	SM_SkillSet( id, skill_id )
}






//-------------------------------------------
// SM_GetSkillType
//
// Function will simply return the skill type
//-------------------------------------------
SM_GetSkillType( skill_id )
{
	if ( !IsValidSkill( skill_id ) )
	{
		WC3_Log( false, "[2] Invalid skill: %d", skill_id )
		log_error( AMX_ERR_NATIVE, "[2] Invalid skill: %d", skill_id )
		return 0
	}

	return g_SkillType[skill_id]
}



//-------------------------------------------
// SM_TotalSkillPointsUsed
//
//-------------------------------------------
SM_TotalSkillPointsUsed( id )
{
	static i, iTotal, iSkillID
	iTotal = 0

	for( i = 0; i < g_NumAvailableSkills[id]; i++ )
	{
		iSkillID = g_AvailableSkills[id][i]
		iTotal += g_PlayerSkillLevel[id][iSkillID]
	}

	return iTotal
}




//-------------------------------------------
// SM_GetSkillOfType
//
// Function will return a skill of a certain type
//-------------------------------------------
SM_GetSkillOfType( id, type, iStartSkill = SKILL_NONE )
{
	new i, iSkillID, iStart = 0

	if( iStartSkill != SKILL_NONE )
	{
		for( i = 0 ; i < g_NumAvailableSkills[id] ; i++ )
		{
			iStart++
			if( g_AvailableSkills[id][i] == iStartSkill )
				break
		}

		if( iStart >= g_NumAvailableSkills[id] )
			return SKILL_NONE
	}

	for( i = iStart; i < g_NumAvailableSkills[id]; i++ )
	{
		iSkillID = g_AvailableSkills[id][i]

		if( g_SkillType[iSkillID] == type )
			return iSkillID
	}
	return SKILL_NONE
}



//-------------------------------------------
// SM_SetSkill
//
// After we know which skill to give the user - we call this function to give it to them!
//-------------------------------------------
SM_SetSkill( id, iSkillID )
{
	if ( !IsValidSkill( iSkillID ) )
	{
		WC3_Log( false, "[40] Invalid skill: %d", iSkillID )

		log_error( AMX_ERR_NATIVE, "[40] Invalid skill: %d", iSkillID )

		return
	}

	// Get the user's current skill level
	new iCurrentLevel = SM_GetSkillLevel( id, iSkillID, 10 )

	if ( iCurrentLevel + 1 > g_SkillMaxLevel[iSkillID] )
	{
		WC3_Log( true, "Attempted to increase skill %d to %d", iSkillID, iCurrentLevel + 1 )
		return
	}

	// Add one to their level!
	SM_SetSkillLevel( id, iSkillID, iCurrentLevel + 1, 6 )

	new iSkillType = SM_GetSkillType( iSkillID )
	if( iSkillType == SKILL_TYPE_ULTIMATE )
	{
		if( SM_GetSkillLevel( id, iSkillID ) > 0 )
			PlayerInfo[id][PI_SelectedUltimate] = iSkillID
	}

	else if( iSkillType == SKILL_TYPE_ABILITY )
	{
		if( SM_GetSkillLevel( id, iSkillID ) > 0 )
			PlayerInfo[id][PI_SelectedAbility] = iSkillID
	}
}


//-------------------------------------------
// SM_SkillSet
//
// After a user's skill has changed - the skill is configured here!
//-------------------------------------------
SM_SkillSet( id, iSkillID )
{
	switch( iSkillID )
	{
		case SKILL_SPRINT:
			PLAYER_UpdateSpeed( id )

		case SKILL_LEVITATION:
			PLAYER_UpdateGravity( id )

		case SKILL_DEVOTION:
			PALADIN_DevotionAura( id )

//		case ABILITY_SERPENTWARD:
//			HUNTER_SerpentWard( id )
	}
	
	new iSkillType = SM_GetSkillType( iSkillID )
	if( iSkillType == SKILL_TYPE_ULTIMATE )
	{
		if( SM_GetSkillLevel( id, iSkillID ) > 0 )
			PlayerInfo[id][PI_SelectedUltimate] = iSkillID
	}

	else if( iSkillType == SKILL_TYPE_ABILITY )
	{
		if( SM_GetSkillLevel( id, iSkillID ) > 0 )
			PlayerInfo[id][PI_SelectedAbility] = iSkillID
	}

}
